// pages/detail/detail.js
Page({
  data: {
    productId: '', // 从列表页传入的商品ID
    product: {}    // 商品详情数据
  },

  onLoad(options) {
    // 接收列表页传递的商品ID
    this.setData({
      productId: options.id
    });
    
    // 根据ID获取商品详情
    this.loadProductDetail();
  },

  // 加载商品详情
  loadProductDetail() {
    // 这里应该是API请求，示例用模拟数据
    const mockData = this.getMockData(this.data.productId);
    
    this.setData({
      product: mockData
    });
  },
  getMockData(id) {
    const mockProducts = {
      '1': {
        id: '1',
        name: '维嘟香蕉飞饼',
        price: '500',
        originalPrice: '600',
        description: '精选优质香蕉，口感香甜软糯，外酥里嫩',
        images: [
          '/images/food/product1.jpg',
          '/images/foodDetail/product1.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p><p>保质期：12个月</p><p>储存条件：-18℃冷冻保存</p>'
      },
      '2': {
        id: '2',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product2.jpg',
          '/images/foodDetail/product2.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '3': {
        id: '3',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product3.jpg',
          '/images/foodDetail/product3.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '4': {
        id: '4',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product4.jpg',
          '/images/foodDetail/product4.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '5': {
        id: '5',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product5.jpg',
          '/images/foodDetail/product5.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '6': {
        id: '6',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product6.jpg',
          '/images/foodDetail/product6.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '7': {
        id: '7',
        name: '维嘟香蕉飞饼',
        price: '500',
        originalPrice: '600',
        description: '精选优质香蕉，口感香甜软糯，外酥里嫩',
        images: [
          '/images/food/product7.jpg',
          '/images/foodDetail/product7.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p><p>保质期：12个月</p><p>储存条件：-18℃冷冻保存</p>'
      },
      '8': {
        id: '8',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product8.jpg',
          '/images/foodDetail/product8.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '9': {
        id: '9',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product9.jpg',
          '/images/foodDetail/product9.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '10': {
        id: '10',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product10.jpg',
          '/images/foodDetail/product10.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '11': {
        id: '11',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product11.jpg',
          '/images/foodDetail/product11.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '12': {
        id: '12',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product12.jpg',
          '/images/foodDetail/product12.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      },
      '13': {
        id: '13',
        name: '维嘟香葱飞饼', 
        price: '480',
        description: '香葱风味，咸香可口',
        images: [
          '/images/food/product13.jpg',
          '/images/foodDetail/product13.jpg'
        ],
        detail: '<p><strong>产品参数：</strong></p><p>规格：500g/包</p>'
      }
    };
    
    return mockProducts[id] || {};
  },
});